#ifndef __M_LEVEL_H__
#define __M_LEVEL_H__

#include <iostream>

/*
    定义日志等级
    将日志等级转化为字符串
*/

namespace log
{
    class LogLevel
    {
    public:
        enum class Level//枚举类
        {
            UNKNOWN,
            DEBUG,
            INFO,
            WARNING,
            ERROR,
            FATAL,
            OFF
        };

        static const std::string GetLevelString(LogLevel::Level level)
        {
            #define TOSTRING(name) #name // 转换为字符串
            switch (level)
            {
            case LogLevel::Level::DEBUG:
                return TOSTRING(DEBUG);
                break;
            case LogLevel::Level::INFO:
                return TOSTRING(INFO);
                break;
            case LogLevel::Level::WARNING:
                return TOSTRING(WARNING);
                break;
            case LogLevel::Level::ERROR:
                return TOSTRING(ERROR);
                break;
            case LogLevel::Level::FATAL:
                return TOSTRING(FATAL);
                break;
            }
            return TOSTRING(UNKNOWN);
        }
    };
}

#endif
